home *** CD-ROM | disk | FTP | other *** search
- {MEXAMPLE.PAS / EXAMPLE FOR THE MOUSE}
- {WRITING BY THE KING IN 10/13/95 }
-
- Uses Crt; {USING CRT FOR THE EXAMPLE}
- Type
- {This is the For the buttons}
- ButtonType = (None,Left,Right,LeftRight);
- {MouseType is the type for all the details we need for it}
- {X,Y Are the positions of the mouse}
- {Buttons is the buttons that pressed}
- {1 = LEFT BUTTON}
- {2 = RIGHT BUTTON}
- {3 = LEFT AND RIGHT BUTTONS}
-
- MouseType = Record
- X,Y:Word;
- Buttons : ButtonType;
- End;
-
- Var
- Mouse:MouseType;
- Button : String;
-
- {This function get us the status of the mouse}
- Procedure GetMouse(Var Mouse:MouseType);Assembler;
- Asm
- Push Ds {Saving DS}
- Mov Ax,0003h {Function 0003H INT 33H GET STATUS}
- Int 33h
- Lds Si,Mouse {[DS:SI] = MOUSE}
- Shr CX,3 {FOR DIVIDE IT WITH 8}
- Shr DX,3
- Mov [Ds:Si],CX {[DS:SI] = X = CX}
- Mov [Ds:Si+2],DX {[DS:SI+2] = Y = DX}
- Mov [DS:Si+4],BX {[DS:SI+4] = BUTTON = BX}
- Pop Ds {Restoring DS}
- End;
-
- {Thus function Reseting the mouse and return true if the mouse is installed}
- Function ResetMouse:Boolean;Assembler;
- Asm
- Mov Ax,0000h
- Int 33h
- End;
-
- {Show the mouse on the screen}
- Procedure ShowMouse;Assembler;
- Asm
- Mov Ax,0001h
- Int 33h
- End;
-
- Procedure HideMouse;Assembler;
- Asm
- Mov Ax,0002h
- Int 33h
- End;
- Begin
- Clrscr;
- If Not ResetMouse Then
- Writeln('Mouse Driver Not Installed !')
- Else
- Writeln('Mouse Installed !');
- Writeln('"ESC" To Exit..');
- ShowMouse;
- Repeat
- GetMouse(Mouse);
- GotoXy(1,3);
- Writeln('X = ',Mouse.X , ' ');
- Writeln('Y = ',Mouse.Y , ' ');
- Case Mouse.Buttons Of
- NONE : BUTTON := 'NONE';
- LEFT : BUTTON := 'LEFT';
- RIGHT: BUTTON := 'RIGHT';
- LEFTRIGHT : BUTTON :='LEFT AND RIGHT';
- End;
- Writeln('BUTTONS = ',BUTTON+' ');
- Until(Port[$60]=1);
- HideMouse;
- End.